package com.ECPDemo.contant;

import java.util.Arrays;
import java.util.List;

public enum OrderStatusContant {
	
	UNPAID("未付款",1),
	PAID("已付款",2),
	NOT_SHIPPED("未发货",3),
	SHIPPED("已发货",4),
	TRANSACTION_SUCCESS("交易成功",5),
	TRANSACTION_CLOSED("交易关闭",6);
	
	private OrderStatusContant(String name,Integer id){
		this.name=name;
		this.id=id;
	}
	
	private String name; 

	private Integer id;
	
	/**
	 * 重写父类方法，便于程序中比较
	 */
	public String toString() {
		return this.id+"";
	}
	
	 /**
     * 通过ID 查找名字
     */
   	public String findName(long Id){
   		OrderStatusContant[] tyList = OrderStatusContant.values();
   		for (int i = 0; i < tyList.length; i++) {
			if(tyList[i]!=null && tyList[i].id==Id){
				return tyList[i].name;
			}
		}
   		return "";
   	}
   	
    /**
     * 查询所有的类型
     */
   	public List<OrderStatusContant> findAll(){
   		OrderStatusContant[] tyList = OrderStatusContant.values();
   		return Arrays.asList(tyList);
   	}
   	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
}
